﻿package mortal.game.proxy
{
    import Framework.Util.*;
    import Message.Game.*;
    import com.gengine.debug.*;
    import extend.language.*;
    import mortal.common.error.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.view.flowerSend.data.*;
    import mortal.mvc.core.*;

    public class FriendProxy extends Proxy
    {
        private var _friendCache:FriendCache;
        private var _replyData:Object;

        public function FriendProxy()
        {
            this.init();
            return;
        }// end function

        private function init() : void
        {
            this._friendCache = this.cache.friend;
            return;
        }// end function

        public function apply(param1:Array) : void
        {
            rmi.iFriendPrx.apply_async(new AMI_IFriend_apply(this.applySucc, null, param1), param1);
            return;
        }// end function

        private function applySucc(param1:AMI_IFriend_apply) : void
        {
            MsgManager.showRollTipsMsg(Language.getString(20551));
            var _loc_2:* = param1.userObject as Array;
            NetDispatcher.dispatchCmd(ServerCommand.FriendApplySucc, _loc_2);
            return;
        }// end function

        public function reply(param1:Array, param2:int, param3:int) : void
        {
            this._replyData = {};
            this._replyData["ids"] = param1;
            this._replyData["replyType"] = param2;
            rmi.iFriendPrx.reply_async(new AMI_IFriend_reply(this.replySuccess, this.replyFail, this._replyData), param1, param2, param3);
            return;
        }// end function

        private function replySuccess(param1:AMI_IFriend_reply) : void
        {
            NetDispatcher.dispatchCmd(ServerCommand.FriendApplyListUpdate, param1.userObject);
            return;
        }// end function

        private function replyFail(param1:Exception) : void
        {
            MsgManager.showRollTipsMsg(ErrorCode.getErrorStringByCode(param1.code));
            NetDispatcher.dispatchCmd(ServerCommand.FriendApplyListUpdate, this._replyData);
            return;
        }// end function

        public function removeAll(param1:int, param2:Array = null) : void
        {
            if (param2 == null)
            {
                param2 = [];
            }
            rmi.iFriendPrx.removeAll_async(new AMI_IFriend_removeAll(), param2, param1);
            return;
        }// end function

        public function moveIntoList(param1:Number, param2:int, param3:int) : void
        {
            rmi.iFriendPrx.moveIntoList_async(new AMI_IFriend_moveIntoList(), param1, param2, param3);
            return;
        }// end function

        public function changeRemark(param1:Number, param2:int, param3:String) : void
        {
            rmi.iFriendPrx.changeRemark_async(new AMI_IFriend_changeRemark(), param1, param2, param3);
            return;
        }// end function

        public function getFriendList(param1:int) : void
        {
            rmi.iFriendPrx.getFriendList_async(new AMI_IFriend_getFriendList(this.getFriendsSuccess, this.getFriendsFail), param1);
            return;
        }// end function

        private function getFriendsSuccess(param1:AMI_IFriend_getFriendList, param2:Array) : void
        {
            NetDispatcher.dispatchCmd(ServerCommand.GetFriendList, param2);
            return;
        }// end function

        private function getFriendsFail(param1:Exception) : void
        {
            Log.debug("获取好友列表数据失败");
            NetDispatcher.dispatchCmd(ServerCommand.GetFriendList, []);
            return;
        }// end function

        public function addToBlackList(param1:int) : void
        {
            rmi.iFriendPrx.addToBlackList_async(new AMI_IFriend_addToBlackList(), param1);
            return;
        }// end function

        public function getOneKeyMakeFriendsInfo() : void
        {
            rmi.iFriendPrx.getOneKeyMakeFriendsInfo_async(new AMI_IFriend_getOneKeyMakeFriendsInfo(this.getSuccess));
            return;
        }// end function

        private function getSuccess(param1:AMI_IFriend_getOneKeyMakeFriendsInfo, param2:Array) : void
        {
            NetDispatcher.dispatchCmd(ServerCommand.GetOneKeyMakeFriendsInfo, param2);
            return;
        }// end function

        public function oneKeyMakeFriends(param1:Array) : void
        {
            rmi.iFriendPrx.oneKeyMakeFriends_async(new AMI_IFriend_oneKeyMakeFriends(), param1);
            return;
        }// end function

        public function changeFriendType(param1:Number, param2:int, param3:int) : void
        {
            rmi.iFriendPrx.changeFriendType_async(new AMI_IFriend_changeFriendType(), param1, param2, param3);
            return;
        }// end function

        public function congratulate(param1:Array) : void
        {
            rmi.iFriendPrx.congratulate_async(new AMI_IFriend_congratulate(null, this.congratulateFail), param1);
            return;
        }// end function

        private function congratulateFail(param1:Exception) : void
        {
            MsgManager.showMouseMsg(ErrorCode.getErrorStringByCode(param1.code), MsgRollTipsType.msgRollTips3);
            return;
        }// end function

        public function getCongratulateRewards() : void
        {
            rmi.iFriendPrx.getCongratulateRewards_async(new AMI_IFriend_getCongratulateRewards(null, this.getFail));
            return;
        }// end function

        private function getFail(param1:Exception) : void
        {
            MsgManager.showMouseMsg(ErrorCode.getErrorStringByCode(param1.code), MsgRollTipsType.msgRollTips3);
            return;
        }// end function

        public function sendFlowers(param1:FlowerSendData) : void
        {
            rmi.iFriendPrx.sendFlowers_async(new AMI_IFriend_sendFlowers(this.sendSuccess, null, param1), param1.toPlayer.name, param1.itemData.itemCode, param1.autoBuy, param1.anonymous);
            return;
        }// end function

        private function sendSuccess(param1:AMI_IFriend_sendFlowers, param2:Object = null) : void
        {
            var _loc_3:* = param1.userObject as FlowerSendData;
            NetDispatcher.dispatchCmd(ServerCommand.FlowerSendSuccess, _loc_3);
            return;
        }// end function

        public function kissBack(param1:String) : void
        {
            rmi.iFriendPrx.kissBack_async(new AMI_IFriend_kissBack(), param1);
            return;
        }// end function

    }
}
